package moon.core.classdef;
import moon.core.Name;
import moon.core.entity.SignatureEntity;

/** 
 * Formal argument in the signature of a method.
 * 
 * @author <a href="mailto:rmartico@ubu.es">Ra&uacute;l Marticorena</a>
 * @since JavaMoon-1.3
 */
@SuppressWarnings("serial")
public abstract class FormalArgument extends SignatureEntity {
	
	/**
	 * Separator character used in name convention.
	 */
	private static final String SEPARATOR = "#";
	
	/**
	 * Method declaration.
	 */
	private MethDec methDec;
    
	/**
     * Constructor.
     * 
     * @param name name
     * @param type type
     */
    public FormalArgument(Name name, Type type) {
        super(name, type);
    }
    
    /**
     * Returns the method of the formal argument.
     * 
     * @return origin method
     * @since JavaMoon-1.3.5
     * @see #setMethDec
     */
    public MethDec getMethDec(){
    	return methDec;
    }
    
    /**
     * Changes the class of the attribute.
     * 
     * @param methDec new method
     * @since JavaMoon-1.3.5
     * @see #getMethDec
     */
    public void setMethDec(MethDec methDec){
    	this.methDec = methDec;
    }
    
    /**
     * Implements abstract method NamedObject.getUniqueName.
     * {@inheritDoc}
     * 
     * Name convention: namespace.classname#methodnameo#formalargumentname
     *   
     * @return {@inheritDoc}
     * @since JavaMoon-1.3.5
     */
    @Override
    public Name getUniqueName(){    	
    	return  this.getMethDec().getUniqueName().concat(SEPARATOR 
    			+ this.getType().getUniqueName().toString() 
    			+ ":" + this.getName().toString()
    			+ "(" + this.getLine() + ")");    	
    }    
    
    /**
     * {@inheritDoc}.
     * 
     * @return {@inheritDoc}
     */
    @Override
    public ClassDef getClassDef(){
    	return this.getMethDec().getClassDef();
    }
} // FormalArgument
